package vp.remedies.dr.home.fragment;

import java.util.ArrayList;

import vp.remedies.dr.home.R;
import vp.remedies.dr.home.activity.TypesofDiseasesActivity;
import vp.remedies.dr.home.adapter.GridviewAdapter;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.Toast;

@SuppressLint("ValidFragment")
public class TypesOfDiseasesFragment extends Fragment {


	/** Called when the activity is first created. */

	private GridviewAdapter mAdapter;
	private ArrayList<String> listCountry;
	private ArrayList<Integer> listFlag;

	private GridView gridView;

	public TypesOfDiseasesFragment() {
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View rootView = inflater.inflate(R.layout.types_of_diseases, container,
				false);

		prepareList();
		
		// prepared arraylist and passed it to the Adapter class
		mAdapter = new GridviewAdapter(getActivity(), listCountry, listFlag);

		// Set custom adapter to gridview
		gridView = (GridView) rootView.findViewById(R.id.gridView1);
		gridView.setAdapter(mAdapter);

		// Implement On Item click listener
		gridView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1,
					int position, long arg3) {
				Toast.makeText(getActivity(), mAdapter.getItem(position),
						Toast.LENGTH_SHORT).show();
				Intent i = new Intent(getActivity(), TypesofDiseasesActivity.class);
				String diseas_type = "" + (position+1);
				i.putExtra(TypesofDiseasesActivity.DISEAS_TYPE , diseas_type);
				startActivity(i);
			}
		});

		return rootView;
	}

	public void prepareList() {
		listCountry = new ArrayList<String>();

		listCountry.add(this.getString(R.string.eyes_disease_en));
		listCountry.add(this.getString(R.string.children_diseases_en));
		listCountry.add(this.getString(R.string.fever_en));
		listCountry.add(this.getString(R.string.chest_and_lungs_en));
		listCountry.add(this.getString(R.string.hands_and_legs_en));
		listCountry.add(this.getString(R.string.ear_diseases_en));
		listCountry.add(this.getString(R.string.mental_diseases_en));
		listCountry.add(this.getString(R.string.oral_diseases_en));
		listCountry.add(this.getString(R.string.stomach_diseases_en));
		listCountry.add(this.getString(R.string.male_diseases_en));
		listCountry.add(this.getString(R.string.female_diseases_en));
		listCountry.add(this.getString(R.string.sex_diseases_en));
		listCountry.add(this.getString(R.string.skin_problems_en));
		listCountry.add(this.getString(R.string.intestinal_diseases_en));
		listCountry.add(this.getString(R.string.hair_problems_en));
		listCountry.add(this.getString(R.string.injuryboilsandpimples_en));
		listCountry.add(this.getString(R.string.teeth_diseases_en));
		listCountry.add(this.getString(R.string.throat_diseases_en));
		listCountry.add(this.getString(R.string.skin_gastricandbelches_en));
		listCountry.add(this.getString(R.string.kidney_diseases_en));
		listCountry.add(this.getString(R.string.diseases_of_the_anus_en));
		listCountry.add(this.getString(R.string.heart_and_blood_en));
		listCountry.add(this.getString(R.string.parkinsonism_en));
		listCountry.add(this.getString(R.string.cough_en));
		listCountry.add(this.getString(R.string.stool_problems_en));
		listCountry.add(this.getString(R.string.nasal_diseases_en));
		listCountry.add(this.getString(R.string.nerves_en));
		listCountry.add(this.getString(R.string.bones_diseases_en));
		listCountry.add(this.getString(R.string.bile_diseases_en));
		listCountry.add(this.getString(R.string.other_diseases_en));
		

		listFlag = new ArrayList<Integer>();
		listFlag.add(R.drawable.i1);
		listFlag.add(R.drawable.i2);
		listFlag.add(R.drawable.i3);
		listFlag.add(R.drawable.i4);
		listFlag.add(R.drawable.i5);
		listFlag.add(R.drawable.i6);
		listFlag.add(R.drawable.i7);
		listFlag.add(R.drawable.i8);
		listFlag.add(R.drawable.i9);
		listFlag.add(R.drawable.i10);
		listFlag.add(R.drawable.i11);
		listFlag.add(R.drawable.i12);
		listFlag.add(R.drawable.i13);
		listFlag.add(R.drawable.i14);
		listFlag.add(R.drawable.i15);
		listFlag.add(R.drawable.i16);
		listFlag.add(R.drawable.i17);
		listFlag.add(R.drawable.i18);
		listFlag.add(R.drawable.i19);
		listFlag.add(R.drawable.i20);
		listFlag.add(R.drawable.i21);
		listFlag.add(R.drawable.i22);
		listFlag.add(R.drawable.i23);
		listFlag.add(R.drawable.i24);
		listFlag.add(R.drawable.i25);
		listFlag.add(R.drawable.i26);
		listFlag.add(R.drawable.i27);
		listFlag.add(R.drawable.i28);
		listFlag.add(R.drawable.i29);
		listFlag.add(R.drawable.i30);
	}
}
